function ontpost()
{
    var data = $('#form1').serialize();
    var action = $('#form1').attr('action');
    $.post(action,data,function(data){
        if(data.data.type == 'success'){
            swal({
                title: data.data.title,
                type:  data.data.type
            },function(){window.location= data.data.url})
        } else{
            swal({
                title: data.data.title,
                type:  'error'
            })
        }
    },'json');
}

function subpost(){
    $.ajax({
        url: $('#form1').attr('action'),
        type: 'POST',
        dataType: "json",
        cache: false,
        data: new FormData($('#form1')[0]),
        processData: false,
        contentType: false
    }).done(function(data) {
        if(data.data.type == 'success'){
            swal({
                title: data.data.title,
                type:  data.data.type
            },function(){window.location= data.data.url})
        } else{
            swal({
                title: data.data.title,
                type:  'error'
            })
        }
    }).fail(function(data) {
        swal({
            title: data.data.title,
            type:  'error'
        })
    });
}


function del(ment) {
     swal({
        title: "您确定要删除吗?",
        text: "删除后将无法恢复",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定删除",
        cancelButtonText: "取消删除",
        closeOnConfirm: false
    },
    function() {
        var url = $(ment).attr('data-url');
        $.post(url,'',function(data){
            if(data.data.type == 'success'){
                swal({
                    title: data.data.title,
                    type:  data.data.type
                },function(){window.location= data.data.url})
            } else{
                 swal({
                    title: data.data.title,
                    type:  data.data.type
                })
            }
        },'json');
        // swal("删除成功！", "您已经永久删除了这条信息。", "success")
    })
}